<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="pragma" content="no-store">
    <meta http-equiv="Cache-Control" content="no-cache,no-store">
    <meta http-equiv="expires" content="0">
    <meta name="format-detection" content="telephone=no"/>
    <meta name="wap-font-scale" content="no">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>刮刮卡</title>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=jDh3pZvkeqUnuKmWZeyEZSuD0GgpoeSq"></script>
    <link rel="stylesheet" href="../common/css/modal-px.css" media="screen" title="no_title" charset="utf-8"/>
    <link rel="stylesheet" href="../common/css/plugins.css" charset="utf-8">
    <style media="screen" title="no_title">@charset "UTF-8";.clear:after{content:'';display:block;clear:both;width:0;height:0}body,ul,ol,li,p,h1,h2,h3,h4,h5,h6,form,fieldset,table,td,img,div{margin:0;padding:0;border:0}ul,ol{list-style-type:none}select,input,img,select{vertical-align:middle}*{margin:0;padding:0;-webkit-tap-highlight-color:rgba(255,255,255,0);font-family:PingFang SC,STHeiti,"Microsoft Yahei","微软雅黑",Helvetica,sans-serif;-webkit-touch-callout:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;outline:0}a:active,a:hover,a:link,a:visited{text-decoration:none;outline:0}ul,li{list-style:none}html,body{width:100%;font-size:20px;background-color:#f0f0f0}html,body{background-color:#fa664a;background:url(./img/red-px.png) repeat;background-size:cover}.wrap{width:100%;min-height:100vh;background:url(./img/sratch-bg.png) no-repeat top center;background-size:100% auto;padding:7rem .5rem .5rem}.wrap .times{font-size:.65rem;color:#d29de9;text-align:center;margin-bottom:1.6rem}.wrap .times i{font-style:normal}.wrap .sratchArea{width:100%;height:8.25rem;background:url(./img/sratchArea-bg.png) no-repeat top center;background-size:100% auto;padding:.45rem .4rem;position:relative}.wrap .sratchArea .base{width:100%;height:7.35rem;line-height:7.25rem;text-align:center;font-size:1.2rem;font-weight:700;color:#a06a03;background-color:#fed90b}.wrap .sratchArea #redux,.wrap .sratchArea canvas{width:14.2rem!important;height:7.35rem!important;position:absolute;top:.45rem;left:.4rem;z-index:2}.wrap .my-prizes{width:13.9rem;height:1.9rem;line-height:1.9rem;display:block;margin:1.225rem auto 0;color:#826507;font-size:.8rem;font-weight:500;background-color:#ffd902;text-align:center;-webkit-border-radius:1.9rem;-moz-border-radius:1.9rem;-ms-border-radius:1.9rem;-o-border-radius:1.9rem;border-radius:1.9rem}.wrap .my-prizes:active{background-color:#ffd206}.wrap .activityInfo{width:100%;padding:.45rem .9rem 0;background-color:#f77a5a;color:#fff;font-size:.7rem;line-height:1rem;margin-top:2.1rem;margin-bottom:.85rem;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem;position:relative}.wrap .activityInfo:before{content:'';display:block;width:5.15rem;height:.875rem;background:url(./img/borderTop.png) no-repeat center;background-size:contain;position:absolute;left:0;top:-.85rem}.wrap .activityInfo .item{padding:.95rem .5rem .6rem;border-bottom:1px solid #f4866f}.wrap .activityInfo .item:last-child{border:0}.wrap .activityInfo .item h4{font-size:.7rem;color:#cc3210;font-weight:600;line-height:1rem;padding:0 0 .6rem 1.1rem;position:relative}.wrap .activityInfo .item h4:before{content:'';display:inline-block;margin-right:.4rem;width:.7rem;height:.7rem;background:url(./img/gift-icon.png) no-repeat center;background-size:contain;vertical-align:baseline;position:absolute;top:.15rem;left:0}.wrap .activityInfo .item.gift h4:before{background:url(./img/gift-icon.png) no-repeat center;background-size:contain}.wrap .activityInfo .item.time h4:before{background:url(./img/time-icon.png) no-repeat center;background-size:contain}.wrap .activityInfo .item.tip h4:before{background:url(./img/tip-icon.png) no-repeat center;background-size:contain}.wrap .activityInfo .item.note h4:before{background:url(./img/note-icon.png) no-repeat center;background-size:contain}.wrap .activityInfo .item p{padding-bottom:.4rem;line-height:1rem}.bombBox{width:100vw;height:100vh;position:fixed;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.4);padding:0 1.75rem;display:none;z-index:100}.bombBox.show{display:block}.bombBox:after{content:'';display:block;clear:both;width:0;height:0}.bombBox .close{width:1.05rem;height:3.425rem;background:url(../common/img/red-close.png) no-repeat bottom center;background-size:100% auto;margin-bottom:1.25rem;float:right}.bombBox .boxContent{width:100%;background:#fff;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem;float:right;padding:0 .975rem 1.35rem}.bombBox .boxContent h3{text-align:center;font-size:.8rem;font-weight:500;padding:.6rem 0}.bombBox .boxContent button{width:6.95rem;height:1.55rem;line-height:1.55rem;outline:0;display:block;background:#fb3131;color:#fff;font-size:.7rem;text-align:center;font-weight:500;margin:1.5rem auto 0;border:0;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.bombBox .boxContent form input{border:1px solid #e5e5e5;display:block;font-size:.65rem;width:100%;height:1.55rem;margin-top:.6rem;padding:0 .5rem;outline:0;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.bombBox.success .boxContent{height:12.5rem;background:url(../common/img/success-bg.png) no-repeat center;background-size:100% 100%}.bombBox.success .boxContent .prizeName{text-align:center;font-size:.7rem;color:#fff;margin-top:3rem}.bombBox.success .boxContent .imgs{margin-top:.85rem}.bombBox.success .boxContent .prizeImg{width:3rem;height:3rem;display:block;margin:0 auto;background-color:#fff;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.bombBox.success .boxContent .sponsorImg{width:3rem;height:1.25rem;display:block;margin:0 auto;background-color:#fff;margin-top:.25rem}.bombBox.success .boxContent button{margin-top:.6rem}.bombBox.fail .boxContent{height:12.5rem;background:url(../common/img/fail-bg.png) no-repeat center;background-size:100% 100%}.bombBox.fail .boxContent button{margin-top:9rem}#main{display:none;}.wrap .sratchArea .base.origin{color:rgb(177,177,177);background-color:rgb(200,200,200)}</style>
</head>
<body style="visibility: hidden;">
<div class="wrap" id="main">
    <div class="times">您有<i>3</i>次抽奖机会，快来试试手气</div>
    <div class="sratchArea">
        <div class="base origin" id="base">刮我中大奖</div>
        <img id="redux" src="./img/gray-cover.png"/>
    </div>
    <a class="my-prizes">我的奖品</a>
    <div class="activityInfo">
        <div class="item gift">
            <h4>奖项设置:</h4>
            <!--<p>苹果Macbook Pro (13.3英寸)</p>-->
            <!--<p>Ipad mini(16G)</p>-->
            <!--<p>激光虚拟投影键盘</p>-->
        </div>
        <div class="item time">
            <h4>活动时间:</h4>
            <p></p>
        </div>
        <div class="item tip">
            <h4>活动说明:</h4>
            <p></p>
        </div>
    </div>
</div>
<div style="display:none;width:0;height:0;">
    <img src="../common/img/fail-bg.png"/>
    <img src="../common/img/success-bg.png"/>
    <div id="container"></div>
</div>
<script type="text/javascript">
    (function (doc, win) {
        var docEl = doc.documentElement,
            resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
            recalc = function () {
                var clientWidth = docEl.clientWidth;
                if (!clientWidth) return;
                // 针对uc横竖屏rem html没有重绘的问题
                var style;
                if (style = document.getElementById("forhtml")) {
                    style.parentNode.removeChild(style);
                }
                style = document.createElement("style");
                style.id = "forhtml";
                document.head.appendChild(style);
                style.appendChild(document.createTextNode("html{font-size:" + 20 * (clientWidth / 320) + "px !important;}"));
            };
        recalc();
        document.body.style.visibility = 'visible';
        if (!doc.addEventListener) return;
        win.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);
        var a = document.getElementsByTagName('a');
        for (var i = 0; i < a.length; i++) {
            a[i].addEventListener('touchstart', function () {
            }, false);
        }
    })(document, window);
</script>
<script type="text/javascript" charset="utf-8"  src='./lib/jquery-2.1.1.min.js'></script>
<script type="text/javascript" charset="utf-8"  src='./lib/jquery.eraser.js'></script>
<script type="text/javascript">var jQuery = $.noConflict();</script>
<script type="text/javascript" charset="utf-8" src="../common/lib/zepto.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/lib/zepto-adapter.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/js/bombBox.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/js/modal.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/js/utils.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/js/GeoUtils.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="../common/js/weixinshare.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var isWechat = false,isAPP = false,isFollow = false,isCode=false,isPart=false,activities={};
        var allPrizes = [],drawReturn='';
        judgeSignPass(function(){
            requestAllowed('scratch',function(data){
                if(allowed.type=='no-login'){
                    $('.wrap .times').text('你还没有登录哦!');
                }else{
                    $('.wrap .times').html('您有<i>'+allowed.surplus_times+'</i>次抽奖机会，快来试试手气');
                }
            });
        });
        requestActInfo('scratch',function(data){
            $('#main').show();
            $('.item.time p').html(data.activity.start_at+'&nbsp;&nbsp;至</br>'+data.activity.end_at);
            $('.item.tip p').html(data.activity.description);
            if(data.activity.background_img){
                $('.wrap').css({
                    'background': 'url('+data.activity.background_img+') no-repeat center top',
                    'background-size': '100% auto',
                });
            }
            //===============================
            activities = data.activity;
            isWechat = (window.parameter.ways == 'wechat');//是否开启微信
            isAPP = (activities.publishing.app.is_open =='on');//是否开启APP
            isFollow = (window.parameter['following']!=1);//是否关注
            isCode = Boolean(activities.publishing.wechat.qr_code[0]);//是否上传二维码
            if(isWechat){
                if(isFollow){
                    isPart = true;
                }else{
                    if(isCode){
                        var qrCode = QRCode(activities.publishing.wechat.qr_code[0]).open();
                    }else{
                        isPart = true;
                    }
                }
            }else{
                //APP
            }
            //===========================
        });
        requestPrizes(function(data){
            allPrizes = data;
            var html = '';
            for(var i=0;i<data.length;i++){
                html += '<p>'+data[i].name+'</p>';
            }
            $('.item.gift').append(html);
        });
        var lockflag = false;
        $('.sratchArea').on('touchstart',function(e){
            if(!isPart){
                if(isSignPass == -2){
                    if (activities.publishing.app.app_urls[0]) {
                        $.confirm('请下载APP参与活动?',
                            function () {
                                location.href = activities.publishing.app.app_urls[0];
                            },
                            function () {
                            }
                        );
                    } else {
                        $.alert('请下载APP参与活动');
                    }
                    return;
                }
                if(isSignPass == -1) {
                    window.location.href = window.location.href + '&noLogin=true';
                    return;
                }
                if(isSignPass == 0){
                    $.alert('非法请求，请在App中打开');
                    return;
                }
            }
            if(act_info.activity.rules.is_spot&&!isInCircle){
                $.toast('不在范围内哦~~');
                return;
            }
            if (lockflag) return;
            lockflag = !lockflag;
            requestDraw({
                act_id: window.parameter['act_id'],
                uid:  window.parameter['uid'],
                type: 'scratch'
            },function(data){
                drawReturn = data;
                $('.wrap .times').html('您有<i>'+data.surplus_times+'</i>次抽奖机会，快来试试手气');
                if(data.is_winning){
                    $('#base').removeClass('origin').text(data.prize.name);
                }else{
                    $('#base').removeClass('origin').text('很遗憾你没有中奖');
                }
                jQuery('#redux').eraser('enable');
            },function(data){
                $('.wrap .times').html('您有<i>'+data.surplus_times+'</i>次抽奖机会，快来试试手气');
                lockflag = false;
            });
        });
        var flag = true;
        function openAddress(){
            var addressModal = new Modal({
                prize: drawReturn.prize,
                yesCallback: function(){
                    clear();
                },
                closeCallback: function(){
                    clear();
                }
            },'address');
            addressModal.open();
        }
        function clear(){
            jQuery('#redux').eraser('reset');
            jQuery('#redux').eraser('disable');
            flag = true;
            lockflag = false;
        }
        jQuery('#redux').eraser({
            enabled: false,
            progressFunction: function(p) {
                if(p>0.4&&flag){
                    flag = false;
                    if(!drawReturn.is_winning){
                        var failModal = new Modal({
                            yesCallback: function(){
                                clear();
                                failModal.close();
                            },
                            closeCallback: function(){
                                clear();
                            }
                        },'fail');
                        failModal.open();
                    }else{
                        var successModal = new Modal({
                            prize: drawReturn.prize,
                            yesCallback: function(){
                                successModal.close();
                                if(drawReturn.prize.type_code=='entity'){
                                    openAddress();
                                }else{
                                    location.href = '/act/common/prizes.html' + location.search;
                                    clear();
                                }
                            },
                            closeCallback: function(){
                                clear();
                            }
                        },'success');
                        successModal.open();
                    }
                }
            }
        });
        //跳转-我的奖品
        $('a.my-prizes').click(function(e){
            e.preventDefault();
            e.stopPropagation();
            if(!window.parameter['uid']){
                window.location.href = window.location.href + '&noLogin=true';
            }else{
                location.href = '/act/common/prizes.html'+location.search;
                $('#redux').eraser('reset');
            }
        });
    });
</script>
</body>
</html>